using MinimalistFoodStreet.BackEnd.Infrastructure.EFCore;
using MinimalistFoodStreet.BackEnd.Infrastructure.Dtos.Response.Tables;
using MinimalistFoodStreet.BackEnd.Infrastructure.Tools;

namespace MinimalistFoodStreet.BackEnd.Server.Server.ResponseExtend.Tables
{
    public static class GoodsEnitityExtend
    {
        public static ResponseGoodsDto ToResponseDto(this Good entity)
        {
            return new ResponseGoodsDto()
            {
                id = entity.GId,
                supplierId = entity.GSupplierId,
                goodTypeId = entity.GGoodTypeId,
                name = entity.GName,
                price = entity.GPrice,
                description = entity.GDescription,
                photo = entity.GPhoto,
                detailImages = entity.GDetailImages,
                specs = entity.GSpecs,
                isDirectly = entity.GIsDirectly,
                isShelve = entity.GIsShelve,
                inventory = entity.GInventory,
                birthday = entity.GBirthday,
                birthdayStr = Tools.TimeToString(entity.GBirthday),
                expiryday = entity.GExpiryday,
                isPromote = entity.GIsPromote,
                topLevel = entity.GTopLevel,
                createTime = entity.GCreateTime,
                createTimeStr = Tools.TimeToString(entity.GCreateTime),
                updateTime = entity.GUpdateTime,
                updateTimeStr = Tools.TimeToString(entity.GUpdateTime),
            };
        }
    }
}